package main.java.org.controller;

import main.java.Exam.pojo.tableVO.StudentScore;
import main.java.Exam.pojo.tableVO.StudentVo;
import main.java.org.result.Result;
import main.java.org.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class StudentController {

    @Autowired
    private StudentService service;
    //获取全部学生账号姓名
    @GetMapping("/student/getdata")
    public Result<List<StudentVo>> getTotalStudent()
    {
        int status=1;
        List<StudentVo>list=service.getStudentData(status);
        return Result.success(list);
    }

    //获取学生的全部试卷分数
    @PostMapping("/student/getstudentscore")
    public Result<List<StudentScore>>getStudentScore(@RequestBody StudentVo studentVo)
    {
        if(studentVo.getUserAccount()==null||studentVo.getName()==null){
            throw new RuntimeException("没有这个学生");
        }
        List<StudentScore>list=service.getStudentTotalScore(studentVo);

        return Result.success(list);
    }

}
